<template>
	<view class="box">
		<view class="box1 tr">

		</view>
		<!--  -->
		<view class="box2">
			<view class="title f24">请输入礼品卡卡号</view>
			<view>
				<input type="number" v-model="num" :max="total" placeholder="点击输入礼品卡卡号">
			</view>
		</view>
		<view class="box3" @click="goDuihuan">立即兑换</view>
	</view>
</template>

<script>
	import {
		cardExchangeApi
	} from '@/api/user.js'
	export default {
		data() {
			return {
				total: 100,
				num: '', //
				id: ''
			}
		},
		onLoad(e) {
			this.id = e.id
		},
		methods: {
			// 立即兑换
			goDuihuan() {
				cardExchangeApi({
					code: this.num,
					user_card_id: this.id
				}).then(res => {
					uni.showToast({
						title: res.message,
						icon: "none"
					})
					uni.navigateTo({
						url: '/pages/state/success/success?type=9'
					})
				}).catch(err => {
					console.log(err)
					uni.showToast({
						title: err.message,
						icon: "none"
					})
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #F5F5F5;
	}
</style>

<style lang="scss" scoped>
	.box {
		.tips {
			width: 750rpx;
			height: 80rpx;
			padding: 0 30rpx;
			line-height: 80rpx;
			font-size: 26rpx;
			color: #F83535;
			background: #FFF3F3;
			box-sizing: border-box;
		}

		.box1 {
			width: 750rpx;
			height: 260rpx;
			background: linear-gradient(179deg, #2BCCA5, #22B591);
			overflow: hidden;
			color: #fff;
			box-sizing: border-box;

			.num {
				margin-top: 50rpx;
				font-size: 80rpx;
			}
		}

		.box2 {
			margin: -180rpx auto 0;
			padding: 0 30rpx;
			width: 690rpx;
			height: 300rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			box-sizing: border-box;
			overflow: hidden;

			.title {
				margin: 100rpx auto 45rpx;
			}

			input {
				font-size: 28rpx;
			}
		}

		.box3 {
			margin: 40rpx auto;
			width: 690rpx;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			color: #fff;
			font-size: 32rpx;
			background: linear-gradient(64deg, #2BCCA5, #22B591);
			box-shadow: 0rpx 4rpx 6rpx 0rpx rgba(20, 187, 146, 0.4);
			border-radius: 10rpx;
		}
	}
</style>
